package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.Company;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SurveyMapper;
import com.ruoyi.system.domain.Survey;
import com.ruoyi.system.service.ISurveyService;

/**
 * 服务调查Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-03
 */
@Service
public class SurveyServiceImpl implements ISurveyService 
{
    @Autowired
    private SurveyMapper surveyMapper;

    /**
     * 查询服务调查
     * 
     * @param surveyId 服务调查主键
     * @return 服务调查
     */
    @Override
    public Survey selectSurveyBySurveyId(Long surveyId)
    {

        return surveyMapper.selectSurveyBySurveyId(surveyId);
    }

    /**
     * 查询服务调查列表
     * 
     * @param survey 服务调查
     * @return 服务调查
     */

    @Override
    public List<Survey> selectSurveyList(Survey survey)
    {

        return surveyMapper.selectSurveyList(survey);
    }


    /**
     * 新增服务调查
     * 
     * @param survey 服务调查
     * @return 结果
     */
    @Override
    public int insertSurvey(Survey survey)
    {
        survey.setFakeDelete(1l);
        survey.setSurveyStatus(0l);
      //  survey.setSurveyTime(DateUtils.getNowDate());
        return surveyMapper.insertSurvey(survey);

    }

    /**0
     * 修改服务调查
     * 
     * @param survey 服务调查
     * @return 结果
     */


    @Override
    public int updateSurvey(Survey survey)
    {
        if (survey.getSurveyResult()!=null&&survey.getSurveyResult()!=""){
            survey.setSurveyStatus(1l);
        }
        return surveyMapper.updateSurvey(survey);
    }

    /**
     * 批量删除服务调查
     * 
     * @param surveyIds 需要删除的服务调查主键
     * @return 结果
     */
    @Override
    public int deleteSurveyBySurveyIds(Long[] surveyIds)
    {
        return surveyMapper.deleteSurveyBySurveyIds(surveyIds);
    }

    /**
     * 删除服务调查信息
     * 
     * @param surveyId 服务调查主键
     * @return 结果
     */
    @Override
    public int deleteSurveyBySurveyId(Long surveyId)
    {
        return surveyMapper.deleteSurveyBySurveyId(surveyId);
    }
}
